package handlers

import (
	"git.hortorgames.com/serverless/htgserver/apiserver"
	"git.hortorgames.com/serverless/htgserver/consts"
)

type MidVerifySign struct {
	Base
}

func NewMidVerifySign(server *apiserver.Server) *MidVerifySign {
	h := &MidVerifySign{}
	h.Server = server
	return h
}

//@httpMid:""
func (h *MidVerifySign) Verify(ctx *apiserver.Context) {
	if ctx.Request().Method != "POST" {
		ctx.Next()
		return
	}
	game := ctx.Game
	if !ctx.VerifySign(game.ClientSecret) {
		ctx.Logger().Error("VerifySign error")
		h.Halt(ctx, consts.ErrorSignError)
		ctx.Abort()
		return
	}
	ctx.Next()
}
